package com.aaa.ssm.service.impl;

import com.aaa.ssm.dao.TptFconTactDao;
import com.aaa.ssm.entity.TptFconTact;
import com.aaa.ssm.service.TptFconTactService;
import com.aaa.ssm.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@Service
public class TptFconTactServiceImpl implements TptFconTactService {

    @Resource
    private TptFconTactDao tptFconTactDao;
    @Override
    public List<TptFconTact> getList(int id) {
        return tptFconTactDao.getList(id);
    }
    /**
     * 分页带参查询
     *
     * @param tptFconTact
     * @return
     */
    @Override
    public PageInfo queryPage(Page<TptFconTact> tptFconTact) {
        PageHelper.startPage(tptFconTact.getPageNo(), tptFconTact.getPageSize());
        return new PageInfo(tptFconTactDao.queryPage(tptFconTact.getData()));
    }

    /**
     * 根据编号查询
     * @param id
     * @return
     */
    @Override
    public TptFconTact queryById(Integer id) {
        List<TptFconTact> tptFconTactDaos = tptFconTactDao.queryById(id);
        if (tptFconTactDaos != null && tptFconTactDaos.size() > 0) {
            return tptFconTactDaos.get(0);
        }
        return null;
    }

    @Override
   public List<TptFconTact> queryPageId(){
//        int userA = (int) session.getAttribute("userA");
        TptFconTact tptFconTact = new TptFconTact();
        tptFconTact.setUserid("1");
        return tptFconTactDao.queryPageId(tptFconTact.getUserid()) ;
    }

    /**
     * 添加数据
     *
     * @param tptFconTact
     * @return
     */
    @Override
    public int TptAdd(TptFconTact tptFconTact) {
        return tptFconTactDao.TptAdd(tptFconTact);
    }

    /**
     * 更新数据
     *
     * @param tptFconTact
     * @return
     */
    @Override
    public int TptUpdate(TptFconTact tptFconTact) {
        return tptFconTactDao.TptUpdate(tptFconTact);
    }

    @Override
    public int TptDelete(Integer id) {
        return tptFconTactDao.TptDelete(id);
    }
}
